#!/usr/bin/python3
# -*- coding:utf-8 -*-
# @Time  : 2021/3/21 13:45
# @File  : test.py

"""
<span class="title">肖申克的救赎</span>
"""

import requests
from bs4 import BeautifulSoup

top_num = 1
url = "https://movie.douban.com/top250?start="
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36'}
urls = [url + str(num * 25) for num in range(4)]

print('----------电影top100----------')

for url in urls:
    r = requests.get(url, headers=headers)
    html = r.text
    soup = BeautifulSoup(html, 'html.parser')
    movies = soup.find_all("span", class_="title")
    for i in movies:
        if i.text.find('/') == -1:
            print('Top' + str(top_num) + ' ' + i.text)
            top_num += 1